USE [texchange_db]
GO

/****** Object:  UserDefinedFunction [dbo].[Fn_GetAllUniversalTypes]    Script Date: 05/29/2011 19:55:59 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE FUNCTION [dbo].[Fn_GetAllUniversalTypes] 
(	
	-- Add the parameters for the function here
	@start  bigint=0,
	@limit bigint=30,
	@order nvarchar(10) = 'id',
	@orderdir nvarchar(4) = 'desc',
	@type_id bigint=1,
	@language_id bigint
)
RETURNS TABLE 
AS
RETURN 
(
	-- Add the SELECT statement with parameter references here
	SELECT [id], [name], [isActive],[language_id],[parent_id] from
			(SELECT *, ROW_NUMBER() OVER (ORDER BY id asc) AS  rownum FROM UniversalType 
			where language_id = @language_id AND type_id = @type_id) as a
		WHERE rownum >=@start AND rownum<=@limit
)



GO


